from google.appengine.ext import webapp
from eutax.robopuzzle.web import util
from eutax.robopuzzle.core.parsers import MapParser
from eutax.robopuzzle.core.parsers import ProgramParser

class ProgramTester(webapp.RequestHandler):
  def get(self):
    self.printResult('')
    
  def post(self):
    input = self.request.get('statements')
    programParser = ProgramParser(input)

    statements = programParser.getStatements()
    self.printResult(statements)

  def printResult(self, statements):
    templateValues = {
      'statements': statements,
      }

    self.response.out.write(util.renderTemplate(self.request.uri, 
                                       templateValues, 
                                       'templates/test/program.html'))
    
